<template>
  <div class="app-container" v-loading="loading.getPageList">
    <div>
      <el-button type="primary" size="small" @click="create">新增</el-button>
      <el-button type="primary" size="small" @click="getPageList"
        >刷新</el-button
      >
    </div>
    <br />

    <el-table :data="tableData" border style="width: 100%">
      <el-table-column type="index" label="序号" width="60"> </el-table-column>
      <el-table-column prop="title" label="表单名称" width="220">
      </el-table-column>
      <el-table-column prop="formType" label="表单类型" width="100">
      </el-table-column>
    
      <el-table-column prop="description" label="描述" width="300">
      </el-table-column>
      <el-table-column prop="activeVersion" label="激活版本" width="100">
      </el-table-column>
        <el-table-column prop="workflowName" label="关联流程" width="150">
        <template slot-scope="scope">
          <span>{{scope.row.workflowName+':'+scope.row.workflowId.version}}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="creationTime"
        :formatter="dateFormat"
        label="创建时间"
        width="160"
      >
      </el-table-column>
      <el-table-column
        prop="modifiedTime"
        :formatter="dateFormat"
        label="更新时间"
        width="160"
      >
      </el-table-column>
      <el-table-column> </el-table-column>

      <el-table-column fixed="right" label="操作" width="280">
        <template slot-scope="scope">
          <el-button
            @click="$refs.updateVersionForm.show(scope.row)"
            type="text"
            size="small"
            >版本切换</el-button
          >
          <el-button @click="edit(scope.row)" type="text" size="small"
            >编辑</el-button
          >

          <el-button @click="remove(scope.row.id)" type="text" size="small"
            >删除</el-button
          >
          <el-button @click="$refs.viewFormDesignForm.show({id:scope.row.id,version:scope.row.activeVersion})" type="text" size="small"
            >查看表单</el-button
          >
          <el-button @click="$refs.workflowDesignForm.show(scope.row.workflowId)" type="text" size="small"
            >流程图</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <br />
    <el-pagination
      background
      layout="sizes,prev, pager, next"
      :total="page.total"
      :page-size="page.maxResultCount"
      :current-page="page.currentPage"
      @current-change="(current) => paginationChange(null, current)"
      @size-change="(size) => paginationChange(size)"
    >
    </el-pagination>

    <createForm ref="createForm" @ok-click="created"></createForm>
    <editForm ref="editForm" @ok-click="getPageList"></editForm>
    <updateVersionForm
      ref="updateVersionForm"
      @ok-click="getPageList"
    ></updateVersionForm>
    <workflowDesignForm ref="workflowDesignForm"></workflowDesignForm>
    <viewFormDesignForm ref="viewFormDesignForm"></viewFormDesignForm>
  </div>
</template>

<script>
import createForm from "./createForm";
import editForm from "./editForm";
import TableIndex from "@/layout/mixin/TableIndex";
import updateVersionForm from "./updateVersionForm";
import workflowDesignForm from '@/views/workflows/workflow/viewWorkflowForm.vue'
import viewFormDesignForm from './viewFormDesignForm'
export default {
  components: { createForm, editForm, updateVersionForm,workflowDesignForm ,viewFormDesignForm},
  mixins: [TableIndex],
  data() {
    return {
      moduleName: "dynamicFormDesign",
      isnew: true,
    };
  },
  methods: {
    created() {
      this.getPageList();
      this.$notify({
          title: '恭喜添加新表单设计',
          message:'可以通过 编辑 对表单进行编辑，自定义表单布局和绑定的字段',
          type: 'success'
        });
    },
    edit(row) {
      this.$router.push({
        path: "/workflowDesign/editPage",
        query: {
          id: row.id,
          version: row.activeVersion || 1,
        },
      });
    },
  },
};
</script>

<style></style>
